import { Injectable } from '@nestjs/common';
import { CreateAaa6Dto } from './dto/create-aaa6.dto';
import { UpdateAaa6Dto } from './dto/update-aaa6.dto';
import { Aaa6 } from './entities/aaa6.entity';
import { AaaVo } from './vo/aaa6.vo';
const database = [
  new Aaa6({ id: 1, username: 'xxx', password: 'xxx', email: 'xxx@xx.com'}),
  new Aaa6({ id: 2, username: 'yyy', password: 'yyy', email: 'yyy@yy.com'})
]
let id = 0

@Injectable()
export class Aaa6Service {
  create(createAaa6Dto: CreateAaa6Dto) {
    const user = new Aaa6(createAaa6Dto)
    user.id = id++
    database.push(user)
    return user;
  }

  findAll() {
    // return database.map(item => {
    //   return new AaaVo({
    //     id: item.id,
    //     username: item.username,
    //     email: item.email
    //   })
    // });
    return database
  }

  findOne(id: number) {
    return database.filter(item =>  item.id === id).at(0);
  }

  update(id: number, updateAaa6Dto: UpdateAaa6Dto) {
    return `This action updates a #${id} aaa6`;
  }

  remove(id: number) {
    return `This action removes a #${id} aaa6`;
  }
}
